There are provided an image forming apparatus and a method of controlling
the same are provided, which are capable of conveying an insert sheet of
a proper page in carrying out a recovery process and simplifying the
recovery process, and a storage medium storing a program for executing
the method. When a printing start instruction is input and an insert mode
has been set, an insert sheet is fed. It is determined whether the insert
sheet is for a top page of a copy (bundle) or not. When the insert sheet
for the top page is detected, a proper printing operation in the insert
mode is started. If the insert sheet is not determined to be for the top
page, it is judged that the insert sheet has not been correctly set on
the inserter tray, and then the insert sheet is discharged to a non-sort
tray. Then, insert sheets are discharged to the non-sort tray until the
insert sheet for the top page is detected.