use higher-order functions