Solved. Used a simple loop and moving window.