fix distance func. it must return home