did some debugging on the termination criteria. not terminating properly