Moved delete before the insert.