bug fixes with legend