Ported to C# way