Working version with pouch as the db