added traversing of list using ArrayList and HashMap