changed variable names from mean to 'invm'