added invert function for pchs