refactored pmi computation