reorganized code better & used better multithreading practices