Fixing javascript error