Code made safe, of undefined error