Added more code, explanatory text, and an image.