fix bugs for name reference