cleanup of setFrequency and code formatting BROKEN