Sliding window with variable window size