Implemented distance option

Heya, I have implemented the distance option and added the appropriate tests.