Henderbot: removes some nesting and reorders operations for efficiency