Added separate functions for ArrayList and LinkedList