Added automatic scaling in distance computation if weights are bigger than 1 or lower than 0