added state transition diagram