Remove promises and replace with recursive generator function