Refactored request code