refactor for else if