if/else was on wrong place