added legend and fixed resizing issues