Separated out iteration function. Should have checked this in with the app.py, oops