Final edit function