add sm wait state logic