fixed error handling + doc