to add thread control