added stat counter code