faster loops, freq functions merged