replace naive/lazy map with a ring buffer