Fixing javascript ref