Move onSuccess and onFail functions in to scope and call ()