replacing long conditionals with function calls