split apart the main script to make tests easier to add