extract the queries to the model