bugfix corrected in weightedSum