replaces queue with database