refactored counter code to use a module to store all counter related methods