refactoring + pre-treatment