Using pid commands more efficiently