Use distance() instead of explicitly using Pythagoras.

Also, the use of position() is no longer required.
Renumber parts