refactoring to use getCodeMirror function.