changed it to used linked lists instead of arrays