added logic to save exam