refactored for security and isolation of form editor