Fixed infinite while loop when calculating tunings