callback hell resolving patch, optimize