replaced linkedlist with arraylist