Edge Client Retarget to Controller

Thanks in advance. Looking for some assistance on a client startup script.

Client fallback works great if the controller was running when the client first launches the controller application, but the issue comes about when the controller was down to start. For this, my client startup script uses system.util.retarget to retarget to the controller gateway project if its status is running, otherwise proceed in booting in the edge app. But, when re-targeting, it is almost like the controller project is opening on the client (edge) gateway and none of the script functions that are only available to the controller are accessible. Any ideas?