Relocated some lines of code

Relocated $x, $y, $z, $level, and $class so that both the if and else statements can use them.