This centralizes the logic so that we have a single implementation. Change-Id: I7a8e60ddd6acde915047b4c9bfc8be737b40c884