Fix Uncaught TypeError

Fixes #1