more rewrite db handling