rewrite code to use {active, once} option