Added undefined handling