Added missing conditions for query functions