Simplified published code for easier implementation.