higher order functions now passing tests