corrected error in function that loads legend