refactor to remove conditionals