Adding more handling for ajax calls