Refactor request processing