fix little bug in getFrequency
using lastIndexOf in getFrequency