Pass pid as a function paramter