refactor table.js