Finally got around to test this and rewrote most of the looping