handle nan when calculating mean