got pointer problem when trying with mean function