use wrap for query functions