Added database query functions