pseudocode algo HPP detection