legend map
cleaned code
fixed some bugs