Added exception handling
Throw correct Error