test logic and NaN fix