added try finally to remove invalid itames from the queue