state diagram and exception handling