fixed if-bug