bugfix on covariance function