fixed a bug in if condition