javascript for tables manipulation updated