moved editor logic into a method to prevent duplication