Refactored code to send a success response