added support for NaNs