Exercise 4 partially working, needs update to the frequency; Better solution is to put all this in a class