added some thread stuff