Bug fix for null query