updated db and query functions