Refactoring exists code