Completed generator function. Added resolve function.