Cut down on duplication using higher order functions.