change error handling to include throwing exceptions.