Refactored the main method into a common base class.