improved the gateway class