Fixing bad javascript prototype definition