Added distance measurement
Refactor