Split out some logic