change to higher order function