refactors to states, concept of a job and generic failure, which can call properly named fail and complete functions