handleChanges() now calls the insert function