Refactord pid