Code written for writing dynamic header with buttons