update the way of finding length of query result