Solution using ES6 to create closuses