more elegant invalid part detection