fixed the insertion of undefined