[LPM] Simplify this code and fix a compile error for compilers that