fixed bug when saving references