time update and weighted covariance code