Duplicated a my code so we can implement multithreading sepparately.