added new distance function based on LZ77