refactored code with resharper