improved emulation
refactoring