update thread creation code a bit