Fixed conditional statement bug