Fix unexpectedly switched "else" and "end"