Fixed bug with distance