purge database loop