tracking on index2.html with the refactored code
legend works