fix promises error handling