Fixing assignment in if statements