Rewrote for new thread design