refactor datatable javascript