update to getEndpoint function