make robust against bad gateway