refactor editor.py