finished most of overall error handling