modified the termination condition after generating the recommendation