legend is working, code is cleaned
starting version 3