finish counting functions