fixed the retreive function