Fixed error that would come up when counting data from a Query