some state handling for error trapping