Refactored code to use environment.start() rather than direct calls to success or failure. This keeps recursion from blowing up the stack.