changed condition's merging to intersection, runs perfectly now,
debugging statements not removed