add error handling and typo code