translated ES6 generators to plain ES5 with callbacks