Refactored to fix bug in production of ooe