JJP: refactoring to closures