replace some newArrayList with copyOf to use immutable list