Separate out into functions