correct sliding window code