Fixing error in if condition