implement some query functions