rewrite database module