added wallDist function