cleaned up the logic a bit more, but still no progress on the looping issues. Hmpf.