refactoring to edit create_thread()