Seperated the engine code from the example