fixed bug in sql query