Cleaned up with a run-main-iteration function