refactor thread create