organizing main.py into discrete functions