added C version in case C# is ~verboten~