The PID algorithm depends on the values of the three coefficients, Kp, Ki and Kd. By adjusting the values of the coefficients, the performance of the controller can be optimised. That is to say, overshoots, undershoots and oscillations can be minimised.
Do some experiments to discover an appropriate set of values. You can use the graph in the Processing app to help you.