Why can't you just use `value` here? You're assigning to frequency in every loop iteration.