add error hanlding.