Refactor set-endpoint