Fixed serial calculation of wall distance