refactoring to embedded mode