fixed logic bug in database lookup (introduced by recent change)