moving creating query to QueryFactory