rewrite active state logic