fixed undefined javasctipt error