query draft

basically finished the query function