Code improvement of create patch feature