Detect & Draw header in simple way

The change was originally done to reduce the loop times as many as possible for speed specifically in IE. However, eventually it also simplified detecting/drawing header.