refactored coroutine support