fix sql_queries