What was the church trying to accomplish in the Middle Ages..?