fixed if-statement bug