rewrite for synchronous reset