Fixing Exceptions in Queries