Fixed bug for if statement