Simplify header detection logic with outdent