added ring buffer