changed linkedlist implementation to arraylist based