bug in mean function