normalized calculation of distaces