oops! forgot to add stages.py. decomposed main for easier modification.