changed linkedlist to arraylist