higher function solution