fixed issue with Uncaught TypeError