fix #6480

This is my first contribution so I hope I have followed the guidelines correctly.
return directly instead of assigning to `$header`