added high order function solution