changed chi mod to p-1