fixed bug in SQL query