Refactored build_request method