updated to throw exceptions