Use typeof instead of instanceof.  @mzgol said to :)