added variance calculation