Modified query to take IEndpoint in constructor