refactor 'select table' operation