Add in some code to check if rag exist before calling it. Prolly best to do the same for the memory db too