Fix problem when deleting record