correctly check for defined