Updated CountFunction