optimize edit and complete