Implemented simpler and better solution to the count problem.