Added logic to make the insertTable() work