Now able to handle empty database.