fixed bug with negative weight values