Fixed a bug in on_change of gateway