function to calculate mean is added which fixes #2