Replace uses of `which` with `type`