function for freq computation