Use ArrayDeque instead of List