added NaN handling and rudimentary qa/qc