refactor main 2