Rewrote gateway fetch function