Fixing broken javascript