Closure-based solution