bug in if statement