Check for undefined early to improve perf