add counter to every state and little fix