weighted outpu added. Part 2 done.