refactor else if statements