Refactored to use interface Map.Entry instead of the implementation SimpleEntry