template editor fix. refactoring