Implemented thread (almost perfect, can move to Part 2 now)