Completed mocha rewrite