Separating out the thread JS into a separate file