fix bad sql queries and db works fine