added loop for traversing map