added error handling by throwing an exception