Refactoring response handling