Factored example into functions to make it easier to read