Added function to calculate MSE.