Fix for conditional queries