finalized legend style and functionality