rewrote the program using datatable class