Refactored endpoint implementation