Added promises error handling