Preping for the distance query