Added countDistinct function