fix variance calculation