Fixed bug with gateways