circular buffer code was an incorrect version