writing ref-retrieve