Fixed bug in conditional statement