Fixed edit function