Moved create_query to table controller + solved bug related with the wrong creation of the queries