add sliding window implementation for counter