moved counter handling to its own process