additional code simplifications using heading array