better subroutines for PE detection