modified to throw exception