Refactoring existing code in C#