fix the query, but bug in window query