implemented higher-order functions task