fix a bug in database that makes counter no longer persistence