query fix to improve counts in params call