Modified for insert and update History Table.