changed order of when record get destroyed