Updated Pages.js to prevent crash on empty database.