fixing frequency calculation and better names to vars
solving conflicts