Fixed pmi calculation with help from Hugo