add thread
clean code