added bean motion detection into compound state machine.