Added moving window code