Fixed exception when db is empty.  Should consider redirecting in the future.