defined some more functions in distmat