Sliding Window version implementation.