refactored buildLexicon into a method