Added hasOwnProperty check to custom header loop