Simplify code blocks - C#