fixed bugs involved checking for typed NA values.