implement sliding window