p39 refactored