implemented sliding window