pid function and tones of bug fixing