added nice useful counter class and fixed bug