pulled out into functions
broken out and commented