updated to dynamically replace the header