Refactored for use in editor