Adding code to sequentially calculate integral