Swapped out one-step for loop for acquisition of an iterator. Cleaned up error checking.