added logic for finalize page