Refactor select_table.js