fixing NA issue; sum / length is mean, but length wasn't using na.rm