Bugfix - Added checks for null documents returned from AJAX call