split code out into functions