fixed the null pointer bug in retrieve