Fix logic in edit