I think the if-statement can be removed because endpoint is being set in the init method.