Improved legend but it is still not displaying correctly