Added handling for empty database