Refactoring phase2