replace list-based queue with array-based queue