Implementation

See explanation here.