343 Add legend example, refactoring