1, You could eliminate the `matchFound` flag if you create a label for your outer `for` loop and call `break` with this label: matchLoop: for (final String[] synonymArr : mSynonyms) { for (int j = 0; j < synonymArr.length; j++) { if (inArr[i].equalsIgnoreCase(synonymArr[j])) { inArr[i] = synonymArr[ROOT_WORD]; break matchLoop; } } } Anyway, I think using labels more or less is bad smell, so try to extract out the loops to separate methods. 2, I'd create at lest a `Word` class which stores the (root)word and its synonyms. I should result more readable the code in the `Synonymiser` class too: public class Word { private final String rootWord; private final Set<String> synomins; public Word(final String rootWord, final Collection<String> synomins) { super(); // TODO: empty String/null check this.rootWord = rootWord; // TODO: convert the input to lowercase (it helps contains()) this.synomins = new HashSet<String>(synomins); this.synomins.add(rootWord); } public static Word createWord(final String rootWord, final String... synonims) { final List<String> synonimList = Arrays.asList(synonims); return new Word(rootWord, synonimList); } public boolean contains(final String word) { // TODO: convert word to lowercase for proper comparison if (synomins.contains(word)) { return true; } return false; } public String getRootWord() { return rootWord; } }