frames out the run query func