added final state diagram