remove unnecessary comparisons with undefined