adding a check for isnan because Windows operates differently than Mac