committing the code after resolving the issue of multithreading