improve weight agorithm