added logic for history update