Split out some logic.