As the end of the error packet is known, it is better to pass around an iterator to that instead of recalculating it.