fixed bug in edit function