Added NaN handling to fornav (probably not the cleanest).