Change error handling and visit_function fixed