fixes some things I didn't like about iterator and cleans up the code