Now sets thread function