fixed some sqlqueries