Fix bug when a reference doesn't exist