refactor main file