Implementation of a circular buffer