code factorization
active state added