fixed scope of the "if"