Minor refactoring of undefined checks