Simplified code and removed redundant parts
Simplified code for coroutines