refactor table loading code to more generic to apply for all table data