refactor js to avoid data attributes in html