Higher order function example working