Modified mean to catch TypeError