adding more proper undefined handling