fixed a bug in window length