adding try catch for the ajax call