high order functions implementation