refactoring

Safe code refactoring with step-by-step approach