changed P range to include only positive numbers