refactored frequency counter for better performance