added logic for rollback