Fix/improve two checks for undefined