Added correct thread implementation