changed last call of any(is.na()) to anyNA()