Fix error check issue