Completed editing mode code