add error undefined check