Fix a bug in database class