Implementing a more efficient diff algorithm