moving legend class outside so I can use it elsewwhere