Fix variance calculation