Refactor main method for clarity