only ask sudo when needed and fixed rechecking cmd handling