Fix for "Uncaught TypeError: Cannot read property '0' of undefined".