cleaned up retrieval.cpp