Small refactor in main function