Changed data structures from linkedlist to arraylist