added error handling to header processing in peer.go