handle the case where non-numeric is element of array, also return NaN for error inputs