Added weights to the average calculation