add function for custom queries, and make sure we close the cursor
updated docs