Yea, this is the third copy of this logic, we should centralize it.