replace LinkedList with ArrayDeque