                 
             case "IDAT":
                 
-                guard actl != nil else { return }
-                guard frames.last != nil else { return }
+                guard actl != nil, fctl != nil, frames.last == nil else { return }
                 
                 data = self.idat
                 
             case "fdAT":
                 
-                guard actl != nil else { return }
+                guard actl != nil, fctl != nil else { return }
                 guard chunk.data.count >= 4 else { return }
                 
                 let data_chunk = FrameDataChunk(data: chunk.data)

    }
    
    var numberOfPages: Int {
        return frames.count
    }
    
    func page(_ index: Int) -> ImageRepBase {

                
                if let _fctl = fctl {
                    frames.append(Frame(prev_frame: frames.last, chunks: chunks, ihdr: ihdr, fctl: _fctl, data: data))
                    data = Data()
                }
                
