fixed edit function