SSB-47: fixing nan error in computing the std deviation and using the proper hierarchy to get the beam string