refactoring code to remove if else statements

This is the refactoring that we talked about the other day.