code clean up and bug fix with datatable