implemented rudimentary sliding window