added multithreading with atoms