fixed error management (closes #10)