implemented calculation of distance to building