fix legends replacement (groups)