added logic to regenerate code if user is deleted