accepts function at 3rd argument