Added legend and filter function