started debugging on last 3 query functions