fix bug when database is empty (eg first use)