Rugg, C.J.
This petition for a writ of mandamus raises questions touching the recount of ballots cast in the city of Quincy for Lieutenant Governor at the State election held on November 8, 1932.
1. One allegation in the petition is that a substantial number of ballots “were not cancelled as required by law.” The facts pertinent to this allegation are that when the ballot presented for deposit by the voter is inserted in the aperture on the top of the ballot box and the handle on the outside of the box is turned, rubber rollers within the box grasp the ballot and draw it into the' box. The rubber rollers are so constructed that one of them is intended to stamp upon the back of each ballot the name of the city, the ward number and precinct number in which the ballot is cast. The roller designed to do this stamping is inked from a pad incorporated into the mechanism in the top of the ballot box. The pad is also a roller which moves on a shaft and is so placed and designed that it is in constant contact with another roller upon whose surface are the stamping letters and figures. The rollers and inking device are in the same separate locked portion of the ballot box. There is no arrangement for the mechanical or automatic replenishment of ink on the inking roller and no replenishment is possible without opening the mechanical portion of the ballot box. During the voting period the amount of ink on the pad can be determined only by opening the upper part of the ballot box and inspecting the pad. The key for such opening is in the sole possession of the police officer on duty at each precinct. The only means of ascertaining whether the cancelling device is in fact stamping the ballots as deposited in the box is by examination of the ballots after they have passed into the box or by examining the cancelling device after opening the mechanical portion of the ballot box. Each ballot box contains on its face a numbering device designed to record the number of ballots passing into the box as deposited by the voters, which operates by means *273of a counting mechanism set in motion only when a ballot is actually passing into the box. Prior to the election due examination as required by law was made of all ballot boxes used in Quincy, and they were found to be in good condition and the inking devices properly inked. No record was made that it was impossible to use any of these ballot boxes as required by G. L. (Ter. Ed.) c. 54, § 66, and so far as could be observed during the voting period no ballot box became impossible of use. These ballot boxes were used exclusively during this election. After the closing of the polls and after counting the ballots removed from the ballot boxes, the election officers caused such ballots to be placed in envelopes, some of which were not sealed; some of the ballots were in envelopes placed in “fiberoid containers” which were then sealed and others were placed in unsealed packages or containers. In other instances, where the “fiberoid containers” were inadequate to hold the filled envelopes, the election officers caused such ballots in unsealed envelopes to be securely tied into bundles. All these “fiberoid containers” and tied bundles were duly delivered to the city clerk of Quincy who immediately caused them to be placed in a steel vault in the city hall and there securely locked, and no person had access thereto except the city clerk and his assistants. The election officers in the several precincts after the close of the polls returned unused ballots, the number of which is unknown, to the city clerk in unsealed packages. These packages were placed by the city clerk in the cellar of the city hall in Quincy in space or room which is not locked. So far as appears said packages have remained in said cellar from the time they were placed there until the present time. At the time of the recount the city clerk turned over to the registrars of voters for counting the ballots contained in the envelopes in his possession and received by him from the election officers. The number of uncancelled ballots is not disclosed on the record but it appears to have been an appreciable number of the ballots that were duly cast and received into the ballot box. Such uncancelled ballots were counted according to their marking by the precinct officers, and it *274is the intention of the respondents to count them according to their marking on the recount.
The election law, G. L. (Ter. Ed.) c. 54, contains ample safeguards as to the count of those who receive ballots and of those who deposit ballots'. It is provided by § 67 that one voting list shall be delivered to the ballot clerks and another to the officers in charge of the ballot box. When a ballot is delivered to a voter, his name shall be checked on the first list and when he deposits his ballot it shall be checked on the second list. Each voter on receiving his ballot, § 76, and again on depositing it in the ballot box, § 83, is required to give his name and, if requested, his address to an election officer, who shall distinctly announce such name. The ballot box is required to have mechanical devices for registering the number of ballots cast. § 33. As soon as the polls are closed, the clerk is required to record the number shown by the register on the ballot box. The election officers are required to count audibly the number of names checked on each voting list and announce the same. Then the presiding officer shall open the ballot box, the ballots are counted audibly, one by one, and the whole number is publicly announced. § 105. All these acts precede the counting of the votes cast for the several candidates. The voting lists, records and ballots must be carefully preserved. § 107. Thus there are four separate and independent methods of ascertaining the number of votes cast. Provision is made for equal representation of both the major political parties in the appointment of election officers and their participation in vital steps in the conduct of the election and the counting of ballots. §§ 13, 14, 67, 105. Nothing in this record suggests any disparity between the number of ballots in the ballot box and the number of names of voters checked on the lists and the number registered by the ballot box. There is no basis for a suggestion that the uncancelled ballots were not actually deposited in the ballot box by duly qualified voters in compliance with all the requirements of the election laws. Manifestly each of these ballots passed through the cancelling device and was subject to its operation.
*275The question to be decided is whether as matter of law these uncancelled ballots thus cast must be rejected and not counted. The answer to this question depends upon the construction to be given to G. L. (Ter. Ed.) c. 54, § 106, the words of which so far as here material are: “If the use of a State ballot box is required, no ballot shall be counted unless it has been deposited in and cancelled by such ballot box, or has been otherwise deposited in accordance with section sixty-six. Only official ballots shall be counted in any election for which they are provided. If a voter marks more names than there are persons to be elected to an office, or if his choice cannot be determined, his ballot shall not be counted for such office.” Section 66 is not relevant to the case at bar.
It is provided by G. L. (Ter. Ed.) c. 54, § 33, that “Ballot boxes shall . . . contain mechanical devices for receiving, registering and cancelling every ballot deposited therein.” There are minute provisions as to the approval of ballot boxes and their purchase, care, custody, repair and inspection by public officers. §§ 26, 28, 29, 31, 32, 33, 37, 38. They must be inspected at the opening of the polls and before the beginning of the balloting by the election officers and publicly shown, as assurance that they are empty, and then immediately be locked or fastened and not thereafter removed from public view until after the polls are closed. It is further provided by said § 66 that thereafter “The ballot box shall not be opened . . . until the polls are closed . . . but in order to make room for ballots, the presiding officer may, in the presence of all the election officers, open the box and pack and press down the ballots therein.” Further provision is made if it becomes impossible to use the ballot box. Thus it appears that there is no statutory provision to enable or permit the election officers to ascertain during the progress of the voting whether the internal mechanism of the ballot box is working. The cancelling device might fail to cancel the ballots and the most careful voter and the most alert election officers have no knowledge of the fact. They are deprived by the statute of any possibility of knowing of such defect in the operation of the *276ballot box, if it occurs. The words of said § 106 as to counting uncancelled ballots in these circumstances must be interpreted in the light of the main design of the election laws and the interpretation given to other more or less similar legislative mandates.
Whether an election statute couched in positive words of command is to be construed as intended to invalidate ballots actually cast under all the sanctions of the law must be determined from a broad view of the end and aim of elections and election law rather than from resort to strict logomachy and syntax. It was said by Chief Justice Shaw in Torrey v. Millbury, 21 Pick. 64, 67, respecting the meaning of “shall” in several sections of a statute as to the assessment of taxes, that “many regulations are made by statute . . . intended to promote method, system and uniformity in the modes of proceeding, the compliance or non-compliance with which, does in no respect affect the rights of . . . citizens.” The word “shall” as used in statutes, although in its common meaning mandatory, is not of inflexible signification and not infrequently is construed as permissive or'directory in order to effectuate a legislative purpose. Cheney v. Coughlin, 201 Mass. 204. Rea v. Aldermen of Everett, 217 Mass. 427, 430. In almost every section of our present election law the word “shall” is used. Manifestly, it could not have been intended that noncompliance with any one of these provisions should invalidate an election. The designation “mandatory” or “directory” often is convenient in discussing the meaning of “shall” and “may” in statutes. It is an aid to interpretation to establish tests by which to measure legislative intent. But all such tests must yield to the underlying .aim of all statutory interpretation, which is to discern the legislative intent disclosed by the enactment as an entirety in the light of its dominant purpose and to declare its appropriate application to particular facts. The regnant design of all election laws is to provide expeditious and convenient means for expression of the will of the voters free from fraud. The right to vote is a precious personal prerogative to be ¡sedulously guarded. Arts. 4, 7, 8, 9 of the Declaration of Rights. The public welfare demands that elections be pro*277tected from fraud. If and when those interests conflict, troublesome problems may arise, but presumably the public welfare must be held paramount. C. 1, § 1, art. 4 of the Constitution. Election laws are framed to afford opportunity for the orderly expression by duly qualified voters of their preferences among candidates for office, not to frustrate such expression. The cardinal rule to be followed by election officers and courts in election matters is to ascertain the intent of the voter as disclosed by the official ballot actually cast and to give effect to that intent by counting the ballot; but, if that intent cannot be satisfactorily ascertained, then to reject the ballot. The intention of the voter must be given effect unless in contravention of some essential mandate of the law. The right to vote is a sacred privilege guaranteed by the Constitution to those lawfully qualified. Every rational intendment is to be made in favor of the rightful exercise of the franchise. That principle pervades and dominates all our decisions and harmonizes them all. The design and purpose of election laws have been stated in numerous decisions. It was said by Mr. Justice Hammond, speaking for the court in Blackmer v. Hildreth, 181 Mass. 29, at page 31: “As stated by Andrews, C.J., in People v. Wood, 148 N. Y. 142, 147, ‘The object of elections is to ascertain the popular will and not to thwart it. The object of election laws is to secure the rights of duly qualified electors and not to defeat them.’ This must be borne in mind in the construction of such statutes, and the presumption is that they are enacted to prevent fraud and to secure freedom of choice, and not by technical obstructions to make the right of voting insecure.” A considerable part of this opinion was quoted and followed by Chief Justice Knowlton, speaking for the court, in Attorney General v. Campbell, 191 Mass. 497, 502. This principle was somewhat amplified and enforced in O’Brien v. Election Commissioners of Boston, 257 Mass. 332, 338-339, and Parrott v. Plunkett, 268 Mass. 202, 205-207. In Commonwealth v. McGurty, 145 Mass. 257, at page 260, it was said by the court speaking through C. Allen, J., respecting the trial of an indictment for alteration of a “ballot cast ... at any election held for the *278choice of public officers” where it appeared that the defendant made altering marks on a ballot duly deposited in the ballot box: “It was not necessary to show that the ballot had been cancelled by a mechanical device, as provided in § 10 of the statute. Such cancellation is not essential to insure the counting of a ballot, since § 12 makes provision for the case where a ballot-box containing such mechanical device cannot be furnished. Besides, the evidence showing that the ballot came from the ballot-box which was actually used in the election would warrant the inference that it had been duly cast within the meaning of § 43.” Said § 10, St. 1884, c. 229, as to the device for cancellation of ballots in the ballot box, was in substance the same as G. L. (Ter. Ed.) c. 54, § 33, and its § 11 as to counting ballots in substance the same as G. L. (Ter. Ed.) c. 54, § 106. The statute under consideration in O’Connell v. Mathews, 177 Mass. 518, St. 1898, c. 548, provided in § 194 that on the back and outside of each official ballot prepared by public authority “shall be printed” certain words followed by “a facsimile of the signature” of the officer by whom the ballot was caused to be prepared, and further, in § 230, that no “ballot without the official endorsement . . . shall be deposited in the ballot box.” It was held that ballots deposited without the official indorsement, if provided for the voter by public authority, should be counted as marked by the voter notwithstanding the statutory prohibition. The court said through Chief Justice Holmes: “If [the ballot is] allowed to be deposited and not counted, the voter is disfranchised. The latter result is not to be admitted without very clear words, and such words would raise a constitutional question which we do not decide.” Irregularities in the conduct of an election, not shown to violate the substantive end for which the election was held, do not invalidate the result. Wheeler v. Carter, 180 Mass. 382. It appeared in Blackmer v. Hildreth, 181 Mass. 29, that a nomination paper for a candidate was filed two days later than the date when by the statute it “ shall be filed.” It was found that all the parties including the town clerk and registrars acted in good faith in receiving the nomination paper and printing the name of the candidate on the official ballot. It *279was held that ballots prepared must be counted notwithstanding the violation of the legislative mandate expressed by ‘ ‘ shall. ” In Attorney General v. Campbell, 191 Mass. 497, the precept for a special election to fill a vacancy in a single office at a regular State election was not issued until the day on which caucuses were held for election of delegates to a convention at which the candidate was nominated, as well as other candidates for other offices. No call for caucuses for such nomination was issued. This was an irregularity of some magnitude. But it was held that although the provisions as to caucuses are binding upon officers to be guided thereby, they may be disregarded in determining the validity of a subsequent election, provided it appears that the will of the electors has been fairly expressed by their ballots. The facts before the court in Ray v. Registrars of Voters of Ashland, 221 Mass. 223, were that a voter used on the official ballot in voting for a single candidate a printed paster not prepared in conformity as to type to the positive requirement of the statute to the effect that the type “shall be” of a designated size. This paster was prepared and used by the voter, yet it was held that his ballot was not invalid but must be counted notwithstanding through the act of the voter alone the letters on the paster were not of statutory size. It appeared in Beauchemin v. Flagg, 229 Mass. 23, that the voter had placed a cross between the name of a candidate and the square designed for such cross. It was held that although the statute required that the voter “shall . . . prepare his ballot by making a cross ... in the square at the right of the name,” the ballot must be counted. The facts in Parrott v. Plunkett, 268 Mass. 202, were that under the law at an annual town meeting one selectman was required to be elected for a term of three years. By mistake the official ballot stated the term to be for one year. It was held that the candidate receiving the larger number of votes was elected for the term of three years notwithstanding the unequivocal words of the official ballot to the contrary. Innocent violation of the positive statutory mandate as to preservation for purposes of a recount of ballots used in an election has been held in Swift v. Registrars of Voters of *280Milton, ante, 264, not to invalidate the election although a complete recount was thereby rendered impossible.
Cases have arisen where the voter has failed on his own part to conform to prerequisites of the law essential to express his preference, and has thereby by his own act disfranchised himself. Flanders v. Roberts, 182 Mass. 524. Brewster v. Sherman, 195 Mass. 222. Andrews v. Registrars of Voters of Easton, 246 Mass. 572. Madden v. Election Commissioners of Boston, 251 Mass. 95. Those are instances where the voter failed to make clear his purpose or tried to express an impossible purpose. The plaintiff in Cole v. Tucker, 164 Mass. 486, although given the opportunity to use the official ballot, insisted upon using a privately prepared ballot, thus trying to set up his own will against the plain terms of the statute. He was attempting to make a disorderly expression of his preference. All these decisions but illustrate the rule we have stated.
This review of our decisions affords plenary examples where the word "shall” in the election laws has not been given such imperative effect as to circumvent the intent of a voter casting a ballot expressive of his purpose in accordance with the provisions of law.
It is plain that in the present case the presence of uncancelled ballots in the ballot box was due solely to the failure of the mechanisms within the ballot box to operate as they were designed, to operate. The voters and election officers conformed to the requirements of the election statutes in every particular. They did everything in their power to make every ballot effective. All their conduct was in order. The voters were blameless. They were and doubtless still are unconscious of the defective mechanism in respect to their particular ballots. The same is true of the election officers. No human being has intermeddled in the matter. The only thing contrary to the statute was that an inanimate mechanism, concerning the care and repair of which nothing appears to have been omitted, commonly and so far as appears theretofore invariably set in motion by the turn of a handle accompanying the act of deposit of the ballot by the voter, did not make the stamp on the ballot which it was designed to *281make. The statute forbade any opening of the ballot box to inspect the working of its mechanism, and that was the only way in which its failure to operate in this particular could be discovered. If and so far as there is suggestion in argument that there was opportunity for substitution of ballots by fraud, there is nothing in the record to support it or to overcome the presumption of complete regularity. Independent-Progressive Party v. Secretary of the Commonwealth, 266 Mass. 18. G. L. (Ter. Ed.) c. 54, § 131. The question to be decided, put in paraphrase of the graphic language used in Opinion of the Justices, 178 Mass. 605, at page 618, and quoted with approval in Nichols v. Election Commissioners of Boston, 196 Mass. 410, 415, is whether the expression of the will of the voters is to be nullified by defective “mechanical devices which have no living intelligence, no conscience and no liability to punishment to insure their going right.” To refuse to count the uncancelled ballots would lead to gross injustice to the voters who cast those ballots and which without the fault of any person were not can-celled because of some slip in a mechanism. It would thwart and not secure true expression of the will of the voters. It would tend to subject elections to perplexing technicalities immaterial to the substantial merits of the controversy. It would counteract the free action of the voters. It can hardly be thought that such a result was intended by those who enacted the election laws. We cannot bring our minds to believe that by the words used in said § 106 the General Court has made imperative such a result in the facts here disclosed. In order to effectuate the main design and to carry out the sole purpose of the election law, the absolute words of said § 106 must be held subject to an implied exception where as here the uncancelled ballots were due to no act of man but to the failure of a mechanism prepared with all the care prescribed by law. Other parts of that section may be mandatory. That part respecting cancellation may be mandatory whenever necessary to nullify fraud, individual wrongdoing, or perhaps the strong suspicion or imminent possibility of fraud or wrongdoing. We do not need to pass on those questions. Confining ourselves *282strictly to the facts of the case at bar, where every human step was manifestly innocent and taken as directed by the statute and the only default was by a machine, we are of opinion that the uncancelled ballots ought to be counted. This conclusion is supported by the principles already stated, the quotations from opinions delivered by eminent justices of this court and by actual decisions already summarized. It is confirmed by the numerous provisions of the election law designed to prevent with seeming effectiveness the possibility of unauthorized ballots finding their way into the ballot box and being counted, by permitting only those entitled to vote to receive each a single ballot, to deposit it in the ballot box under close scrutiny, and by requiring triple counting of all persons voting to compare with and as a check upon the number of votes found in the ballot box. This conclusion does not impair the safeguards for purity of elections established by the statutes. It does not open the door to cheating or laxity of conduct. Fraud, stuffing of the ballot box, or other wrongs can be dealt with when they arise. The case at bar in its every aspect presents honesty on the part of every individual concerned. This decision only holds that in such circumstances the statute does not demand disfranchisement of voters.
The decision on this point does not rest upon the provisions of art. 9 of the Declaration of Rights securing the right to vote, nor upon art. 38 of the Amendments to the Constitution as to voting machines. It is an interpretation of the statutes as to elections applied to the facts here disclosed. Constitutional questions which might arise from a rigid and inflexible construction of said § 106 need not be considered. This conclusion is reached having in mind the principle that statutes ought to be so applied as to avoid grave doubts as to their constitutionality. Kennedy v. Commissioner of Corporations & Taxation, 256 Mass. 426, 430. Blodgett v. Holden, 275 U. S. 142, 148.
Adjudications from other jurisdictions have been cited in argument. Some of them contain expressions more or less at variance with what is here decided. Most, if not *283all, of them relate to statutes different in framework and in detail from the one with which we have to deal. They cannot be regarded as persuasive of the decision of the case at bar. • It would serve no useful purpose to review and distinguish or refuse to follow them.
2. A substantial number of absentee ballots were duly delivered to the election officers of the several precincts of Quincy on election day before the hour for closing the polls in the envelopes in which they were received, each envelope containing a notarial certificate. No contention is made that there was not compliance with all the formalities required of election officers by G. L. (Ter. Ed.) c. 54, § 95. After these ballots were counted, they were returned to the city clerk by the election officers, but the envelopes in which they were received were not so returned. These ballots were delivered by the city clerk to the board of registrars for recounting; but no envelopes were so delivered and it is not known where they are. It is provided by § 91 that the city clerk shall mark upon the voting list opposite the name of each person registered as an absent voter the letters in capitals A. V. By said § 95 it is required that all envelopes “shall be retained” with the ballots cast at the election, and preserved and destroyed in the manner provided by law for the retention, preservation or destruction of official ballots, and that the tally sheets in use at elections shall provide in convenient form for the recording thereon of all envelopes of absent voters. There is nothing in the record to indicate fraud or tampering. This failure on the part of election officers to perform the precise duty imposed on them with respect to the envelopes does not invalidate the votes or afford any ground for nullifying the count. This branch of the case falls within the authority of several decisions. O’Connell v. Mathews, 177 Mass. 518. Blackmer v. Hildreth, 181 Mass. 29. Ray v. Registrars of Voters of Ashland, 221 Mass. 223. Swift v. Registrars of Voters of Milton, ante, 264.
3. At the hearing before the single justice there were introduced in evidence eighteen papers agreed to be facsimile reproductions of such portions of eighteen ballots cast at *284the election as were relevant to the present controversy. From an examination of those reproductions he made findings of fact that some were to be counted for one candidate and others were to be counted blanks. This is a proceeding at law. Therefore the findings of fact must stand if as matter of law susceptible of being supported on any rational view of the evidence. They cannot be reviewed or revised. The only question is whether as matter of law they must be reversed. The decision as to the intent of the voter in two or three instances appears on inspection of the papers to be close and difficult. But it cannot be overturned. Andrews v. Registrars of Voters of Easton, 246 Mass. 572. Brewster v. Sherman, 195 Mass. 222.
Petition dismissed.