Rewrite using couch-daemon