implemented AVG distance and their test