Bug fixed sequence generator