Refactoring of pmsi processing