fixing errors due to table insert