added sql query functions