fixed a messed up variable in logic