Move preparation code out into method