rewritten errors handling