Three key steps to help you refactoring legacy code