updated for .NET 4 framework