cleaned up a bit of logic in the main loop, an fix that was already implemented
in the tail case