modularised code and added checkbox at table level