broke some things out into functions