abstracted, commented, and cleaned up app.py module