Fixed database check