Added errors functionality, based on try-catch (rewrite in functional style in future)