finished code for computing mean and var