implemented threads into the program