finished thread implementation