Slight refactoring in main