implemented with a sliding window buffer