changed errors to exceptions