replaced error messages with exceptions