fix previous change, want p within the frequency list inside the loop
still working