Added undefined check at line 76 to prevent an uncaught type error which was occurring when the class attribute was encountered.