consolidated a ton of repeated code into an Endpoint class