Fix gateway bug