fix the bug in queryStats method