add safety feature to sql_free