added support for multiple endpoints