refactoring. added gem counter.