fixed to use Atomicinteger