Move the error handler. The fail method was wrong. Not sure if this is right