Fixed a bug that crashed the code will reading the database.