Fixed a bug with legend