added state diagram