Addition of code for rolling counter