refactors to remove if statements