Much cleaner solution

influenced by official solution.
No more brute force use of the closure. Much more functional.