 		// lastlist check is present to ensure that if
 		// multiple states point to this state, then only
 		//one instance of the state is added to the list
-		if(s == NULL || s->lastlist == dlistid);
+		if(s == NULL);
 		else if (s->c == 257) {
-			s->lastlist = dlistid; 
+			s->lastlist = *dlistid; 
 			PUSH(addStateList, s->out);
 			PUSH(addStateList, s->out1);	
 		}
 		else {
-			s->lastlist = dlistid; 
+			s->lastlist = *dlistid; 
 			l->s[l->n++] = s;
 		}
 	}

        char * lineSegment = bigLine + tableOfLineStarts[i];
        /*PRINT(time, "i:%d\n", tableOfLineStarts[i]);*/

        if (panypmatch(start, lineSegment, &d1, &d2)) 
            PRINT(time, "%s", lineSegment);
	}
	
}

void pMatch(State *start, char * bigLine, u32 * tableOfLineStarts, int lineIndex, int nstate, int time, char * postfix) {
		//printCudaInfo(); 
    
	parallelMatch<<<1,1>>>(start,bigLine,tableOfLineStarts, lineIndex, nstate ,time, postfix);

    cudaThreadSynchronize();

	//TODO free states
    cudaError_t error = cudaGetLastError();

 * to create next NFA state set nlist.
 */
__device__ inline void
pstep(List *clist, int c, List *nlist, int *dlistid)
{
	int i;
	State *s;
	(*dlistid)++;
	nlist->n = 0;
	for(i=0; i<clist->n; i++){
		s = clist->s[i];
	
		if(s->c == c || s->c == Any){
			List addStartState;
			paddstate(nlist, s->out, &addStartState, dlistid);
		}
	}
}

/* Run NFA to determine whether it matches s. */
__device__ inline int
pmatch(State *start, char *s, List *dl1, List *dl2, int * dlistid)
{
	int c;
	List *clist, *nlist, *t;

	clist = pstartlist(start, dl1, dlistid);
	nlist = dl2;
	for(; *s; s++){
		c = *s & 0xFF;
		pstep(clist, c, nlist, dlistid);
		t = clist; clist = nlist; nlist = t;	// swap clist, nlist 
	
		// check for a match in the middle of the string
