moved calculation of relative distance to other file