Adding atomic distance function