Refactored in a successHandler and an errorHandler