Fix moving window break - Optimization moving window