refactored counter method and removed unneeded commented code