Break some code out into a function