refactor main 3