this is old code, I didn't write it, I just put it in an if for handling the insert case