refactor phase 2