Fixed the case when database is not initialized yet.