Avoid Uncaught TypeError