refactored linkedlists instead of arraylists