ugly dynamic array implementation with linked lists