refactoring, and partial main method update.