
68 Ill. App.3d 934 (1979)
386 N.E.2d 341
HARRIS TRUST & SAVINGS BANK, Trustee, et al., Plaintiffs-Appellants,
v.
ILLINOIS FAIR PLAN ASSOCIATION, Defendant-Appellee.
No. 77-736.
Illinois Appellate Court  First District (4th Division).
Opinion filed January 11, 1979.
*935 Gaines and Boyer, of Chicago (Alan I. Boyer, of counsel), for appellants.
Clausen, Miller, Gorman, Caffrey & Witous, P.C. (James T. Ferrini, Frank L. Schneider, and Patricia N. Hale, of counsel), for appellee.
Judgment affirmed.
Mr. JUSTICE ROMITI delivered the opinion of the court:
The issue in this case is whether the insured can recover for a fire loss to his hotel suffered long after he abandoned it on the theory that (1) the insurer by cancelling the policy, said cancellation to be effective in 30 days, is barred from relying on the vacancy clause in the policy or that (2) the insurer, in refunding the unearned premium from the date the cancellation was effective, admitted that the policy was in force before that date and therefore cannot deny coverage. We agree with the trial court that the insured's claims are without merit and affirm the trial court's granting of summary judgment for the defendant.
The parties' pleadings, affidavits and a deposition taken of the *936 plaintiff disclose that the defendant on June 9, 1975, issued a policy protecting the plaintiff's[1] hotel property, both real and personal, from loss by fire and certain other risks for one year. The policy provided in part that the company would not be liable for any loss occurring while the hazard is increased by any means within the insured's knowledge or while the described building was vacant or unoccupied beyond a period of 60 consecutive days. It also provided that the company could cancel the policy at any time by giving the insured a five days' written notice of cancellation with or without tender of the excess of the premium paid over the pro rata premium for the expired time, which excess if not tendered should be refunded upon demand. By statute the period before the notice of cancellation can become effective has been extended to 30 days. Ill. Rev. Stat. 1975, ch. 73, par. 755.16.
On January 18, 1976, the hotel was damaged by fire. No claim is made in the present suit for the loss suffered in that fire. According to the defendant's brief that loss has been paid. (There is nothing in the record to substantiate or disprove this claim.) The plaintiff after the first fire decided that it would cost too much to rehabilitate the building, had it boarded up and abandoned it. From that date no one legally lived in the building. Vagrants, however, have resided in it illegally even after the second fire and property was taken from the building. Despite the abandonment, the plaintiff, for some unknown reason, did not cancel the insurance. The defendant insurer, however, upon discovering that the property was now vacant and unoccupied sent the plaintiff, by certified mail, on March 1, 1976, a notice that the policy was being cancelled effective April 2, 1976, 12 noon. The reason given for the cancellation was "Building Vacant  Open to Trespass." At 5 a.m. on April 2, 1976, the hotel suffered damage from a second fire. The plaintiff has claimed damages in the amount of $186,771.44. The defendant has denied recovery claiming that coverage at the time of the loss was suspended because of the insured's breaches of the vacancy and increase of hazard clauses. Both parties moved for summary judgment. In his motion for summary judgment, the plaintiff for the first time raised the issues of waiver and estoppel. As we already noted, the trial court ruled for the defendant insurer.

I.
It is clear that certain issues are not before this court. First, the plaintiff has never denied that the property was vacant or that his *937 abandonment increased the risk in violation of the policy provisions. Second, the plaintiff has never claimed that the property was left vacant because of some fault of the insurer such as a failure to pay the claim for the first loss or a failure to repair the damage. The plaintiff clearly reveals in his deposition that his decision to abandon the hotel was caused by the economics of the situation and not by any default of the insurer.
 1 The defendant has pointed out on appeal that the plaintiff did not raise the defenses of waiver and estoppel in his pleadings, as required. (Johnson v. Johnson (1975), 26 Ill. App.3d 64, 324 N.E.2d 450; Ill. Rev. Stat. 1975, ch. 110, par. 43(4).) However, it is established that the court is not prohibited from considering affirmative defenses raised in a motion for summary judgment in spite of the fact that those matters had not been raised in the pleadings. (Metropolitan Sanitary District v. Anthony Pontarelli & Sons, Inc. (1972), 7 Ill. App.3d 829, 288 N.E.2d 905, appeal denied (1973), 53 Ill.2d 603.) Furthermore, the parties tried these issues below without any objection by the defendant. Beck v. Capitol Life Insurance Co. (1977), 48 Ill. App.3d 937, 363 N.E.2d 170.

II.
 2 As we noted above, the plaintiff has not denied that it violated the vacancy and increase in hazard provisions of the insurance policy. It is well established that such clauses are valid and enforceable. (Mack v. Liverpool & London & Globe Insurance Co. (1928), 329 Ill. 158, 160 N.E. 222; Dunton v. Connecticut Fire Insurance Co. (7th Cir.1967), 371 F.2d 329.) If one of these clauses is violated, the coverage is suspended until such time as the breach ceases. (Fidelity-Phenix Fire Insurance Co. v. Pilot Freight Carriers, Inc. (4th Cir.1952), 193 F.2d 812; Knight v. United States Fidelity & Guaranty Co. (1971), 123 Ga. App. 833, 182 S.E.2d 693; 6A Appleman, Insurance Law and Practice § 4146 (1972).) Thus, if a loss occurs while the coverage is suspended because of a violation of the policy terms, the insured cannot recover for the loss unless the insurer has waived or is estopped from relying on the policy condition.[2]
Recognizing this, the plaintiff here urges that the defendant is barred by its conduct from relying on the policy conditions. Its basic contention is that "notice of cancellation on a future date and time with knowledge of the vacancy and the possible increase in hazard that may result therefrom waived any right to claim suspension prior to cancellation." We cannot *938 agree with this contention. To the contrary, had the insurer upon learning of the policy violations failed to cancel the policy, it might well have been estopped from relying on the suspension of the policy coverage. (Reinhardt v. Security Insurance Co. (1943), 321 Ill. App. 324, 53 N.E.2d 13; Chas. Kronauer & Co. v. Mechanics Insurance Co. (1932), 266 Ill. App. 477; 16A Appleman, Insurance Law & Practice § 9254 (1968); 17 Appleman, Insurance Law & Practice § 9604 (1945).) Thus, obviously it would be unreasonable to hold that an insurer merely doing what it is required to do to avoid being estopped from relying on its policy provisions is nevertheless barred by that very act from relying on the provisions.
 3 For this reason we agree with the court in Carolina Insurance Co. v. St. Charles (1936), 20 Tenn. App. 342, 98 S.W.2d 1088, that when a violation of the vacancy clause merely acts to suspend coverage, the exercise by the insurer of its reserved right to cancel the policy is not an admission that the policy has been operative during the vacancy.
 4 Likewise, we cannot agree with the plaintiff's contention that because the defendant did not choose to make the cancellation effective until a future date, it waived enforcement of the vacancy and increase of hazard clauses in the interim. The defendant did not elect a future date. It had no choice. The policy was in effect although its protection was suspended. By statute, before the insurer could terminate the policy, it had to give 30 days' notice of cancellation. (Ill. Rev. Stat. 1975, ch. 73, par. 755.16.) This is precisely what the insurer did.
We do not agree with the plaintiff that Franklin Fire Ins. Co. v. Singletary (Tex. Civ. App. 1934), 74 S.W.2d 433, is persuasive. It is true that the court in Singletary held the insurer had waived the breach of the vacancy clause where it, after learning of the breach, cancelled the policy effective several weeks after the discovery. But the policy in Singletary, unlike the one in the present case, voided the coverage if the property was vacant for more than 10 days. That is, if the property was vacant for over 10 days, the coverage was not suspended until the property became occupied again; rather, the policy immediately, without additional notice, terminated. It would not have revived had the insured resumed occupancy of the property. Under those circumstances, the insurer should have simply given notice that the coverage had already terminated. When it chose not to do so but to recognize the policy as still in existence and cancel as of a future date, the court logically held it had waived any right to rely on the prior forfeiture. In the case before us, as we already stated, the policy did not automatically terminate and the insurer, to cancel, was required to comply with the requirements of section 143.16 of the Illinois Insurance Code (Ill. Rev. Stat. 1975, ch. 73, par. 755.16).
 5 The plaintiff, however, contends that the insurer was required to send a notice of suspension as well as a notice of cancellation. The simple *939 answer is that there is no such requirement in the policy. The policy put the insured on notice that if the property was left vacant for more than 60 days or if the hazard were increased, the coverage would be suspended, automatically. The insured is bound by the provisions in the policy. (Soucie ex rel. Ziems v. Illinois Agricultural Mutual Insurance Co. (1944), 323 Ill. App. 456, 56 N.E.2d 55.) And, indeed, it is difficult to see how the insured, who had abandoned the property and was aware that persons illegally resided in it and had stolen some of the contents, could in good faith have possibly believed that the policy, which contained the normal vacancy and increase of hazard clauses, continued to provide protection to the property.

III.
The plaintiff also contends that while under Illinois law an insurer is not obligated to return or offer to return any premium "as a condition precedent to availing itself of its defense to an action on the policy" (Seaback v. Metropolitan Life Insurance Co. (1916), 274 Ill. 516, 522, 113 N.E. 862, 864; Dunton v. Connecticut Fire Insurance Co. (7th Cir.1967), 371 F.2d 329, 331), the defendant's decision to prorate the premiums as of April 2 and its return of the prorated premium after that date is an acknowledgment of the validity of the policy prior to April 2 and a waiver of its claim that the coverage was suspended.[3]
The insured's contention is obviously based on the premise that the insurer was required to refund the premium as of some earlier date  what date the insured does not specify. Since we conclude that the insurer was not obligated to refund the premium for the period before April 2, we need not determine whether retention alone of part of the unearned premium upon cancellation of the policy would create a waiver.
The duty to refund the premium, or part of it, must arise from the policy itself, from statute or from basic established insurance contract principles. The policy itself does not require the insurer to refund the premium if it relies on a breach of a clause in the policy to deny coverage. All it requires is that the insurer, should it elect to cancel the policy, return the excess of the paid premium above the pro rata premiums for the expired term. This, concededly, the insurer has done.
The plaintiff has cited no Illinois statute which requires the refund of the policy premium before the insurer can rely on a provision suspending coverage.
*940  6-8 The general rule at common law is that if the policy is void from the beginning so that the risk never attached, the premiums must be tendered or returned by the insurer to the insured; but if the risk attached, then the insured is not entitled to recover the premiums paid even though the insurer may not be liable because of a subsequent breach by the insured of a policy warranty or condition. (American Insurance Co. v. Woolfolk (1929), 96 Ind. App. 445, 169 N.E. 342; Lemar Towing Co. v. Fireman's Fund Insurance Co. (E.D. La. 1972), 352 F. Supp. 652, aff'd (5th Cir.1973), 471 F.2d 609, cert. denied (1973), 414 U.S. 976, 38 L.Ed.2d 219, 94 S.Ct. 292, 15 Appleman, Insurance Law & Practice § 8366 (1944).) Moreover, there is nothing inconsistent in the insurer's continuing to accept premiums, on the one hand, and relying on limitations on its liability set forth in its policy on the other hand. (Compare Litz v. State Farm Mutual Automobile Insurance Co. (1968), 58 Tenn. App. 585, 435 S.W.2d 124; Ford Life Insurance Co. v. Shannon (Miss. 1976), 328 So.2d 342.) And this is reasonable. After all, the purpose of insurance is to distribute a risk, not to guarantee that there will be a covered loss. The premium is charged on the basis that there may or may not be a loss, not on a certainty that for each premium received there will be a covered loss. If an insurer could only retain a premium where the loss is covered by the policy, insurers would become insolvent. During the 30-day period until the cancellation became effective, there was always a potential if not an actual risk of liability since the insured could at any time have caused the coverage to revive by resuming occupancy. This potential risk did not cease until noon on April 2.
For the foregoing reasons, the judgment of the trial court is affirmed.
Affirmed.
JOHNSON and LINN, JJ., concur.
NOTES
[1]  There are actually two plaintiffs in this case. Since the property was held in a land trust, suit was brought in the name of the trustee Harris Trust and Savings as well as that of the beneficial owner. The real party in interest is the beneficiary of the trust, Alfred Fink. For purposes of simplicity we will simply refer to the plaintiff and the insured as if they were a single party.
[2]  There is one major exception. If the policy is divisible, coverage may be suspended as to certain property or as to certain risks and still be effective as to other property or other risks. (See 4 Appleman, Insurance Law and Practice § 2372 (1969).) Thus, this policy specifically provided that if the contents of two or more buildings were insured, the breach of the policy as to one building would not prejudice the insured's right to recover for a loss occurring to property in a building where at the time of the loss no breach existed.
[3]  The plaintiff accurately makes no claim that the defendant could have been estopped by such conduct. Before an estoppel can be found, the insured must have been misled to its detriment by the insurer's conduct. (Whaley v. American National Insurance Co. (1975), 30 Ill. App.3d 32, 331 N.E.2d 571; 16A Appleman, Insurance Law and Practice § 9088 (1968).) Since the refund was not made until after the loss occurred, it is obvious that under the facts here, there could have been no prejudicial misleading.
