code for sliding window baseline