fixed if statement bug