fix some bugs in add reference