Bug fixes for edit function

Bug fixes for edit function