Fix sudo reference before assignment bug