update exception handling for query