fixed error handling for states 5,8,9 & 10