Add a check for empty database

If statement to check for empty database