semi-working version of legend