papp: code refactoring