added exception handling for search and create document