The code for the emulator