refine sudo logic