refactor main 4-2