Edited version of PO171 Enging code pulled from my archives