switched to using cumsum for differencing, massive speed improvement