created 'createDictionary' method to remove repetition