Adding toArray method code to return headers as an array