refactored retriever model and converted sql annonymous function arrays to classes