fixing get_gateway malloc error issue #21