Added dictionary, refactoring and basic logic