fixed bug in ifstatement