Refactor array iteration with string.equals during tag check, to use hashMap.