I think `threadsToRemove` ends up being the same as `threadIds`, so you can juste reuse it