fully functional counting procedure