This is a fix to incorrect get_next of the sequence.

Nikhil Sontakke provided the patch.