remove else clauses causing undefined variable