modified to work outside of the editor