Added a loop to purge old queues from the database