fixed  a bug with the query