reorganization

created legend creation function
reorganized