fixed bugs in sql queries