updated js to perform for multiple tables on a page