A little refactoring of the gateway