Remade using JS instead of C#