Refactored the code that handles the arguments passed to the ajax request