Replace a magic number by an enum. Turn two if cascades into switches.