class refactoring and multithreading