more typesafe rewrite