added slope calculation over a window