subiterate the weights to retrieve the appropriate value