fix the query problems