LogicMain Refactoring Code