added circular buffer implementation