Tdh merged 2

Doesn't this logic already exist somewhere else? (I don't have the codebase handy at the moment.)