begin of retrieve.r rewrite