added a fail function instead of a then with success callback and fail callback