make sure only valid documents are being transformed