refactoring + main