Added thread implementation