adding circular array/buffer code