Added insert and query functions