Update variable name to ensure consistency
Change TreeMap to HashMap for improved performance and suitability
Update sorting and file output format