Externalized neightbour distance to algorithm