Made it faster using RingBuf