TODO: refactor usages to coroutines as well (cherry picked from commit 7d713b87b1d50accb33e7475d4159ad2db00625f)