Factor code out into the Utils library