Fix issue with temporary gateway logic