add the logic about filter the query history