catching bad state code error