Fix a bug in DatabaseManager