Added a possibility to throw an exception