added in code Brandon White had written for emulation