broke program up into func