corrected comparisons to undefined