re-arrange function order for readability
flake8 (code formatting rules)
mostly commentary on code, reorder for readability