Added legend, and toggle code.