break runner up in to modules so they can be tested, and fixed loop detect to reset on beginning of loop