changed int[] to LinkedList<Integer>