Distance matrix builder first version