moved error throws to centralize them