moved frequency error computation in seperate function