Made it more generic

Used ArrayLists instead of Arrays