step by step refactoring