Refactored code to bind server request callback event to the on functionon