Refactored middleman example