Fixed bug of empty database