use exception to handle error