JS and C# implementation