Replace int counter with AtomicInteger