Changed distance management

The distance is used as it should be in an ideal implementation and it
is changed to 1 inside the coefficients’ calculation.