changing if around undefined