added support for legends