Refactored using ReSharper.