improved slidingN